<?php
/*
Plugin Name: eSfaturi.ro - Facebook like box
Plugin URI: 
Description: Displays the Facebook's like box plugin
Version: 1.0.0
Author: Sergiu Bologa
Author URI: 
License: GPL2
*/

// Start class
class esf_facebook_like_box extends WP_Widget {
	
	// Constructor
	function esf_facebook_like_box() {
		$widget_ops = array( 'classname' => 'esf-social-widget', 'description' => 'Displays the Facebook\'s like box plugin' );
		
		// Widget Settings
		$control_ops = array( 'id_base' => 'esf_facebook_like_box' ); // Widget Control Settings
		$this->WP_Widget( 'esf_facebook_like_box', 'Facebook like box', $widget_ops, $control_ops ); // Create the widget
	}

	// Extract Args
	function widget($args, $instance) {
		extract( $args );
		$title = apply_filters('widget_title', $instance['title']); // the widget title
		
		// Before widget
		echo $before_widget;
		
		// Title of widget
		if ( $title ) { echo $before_title . $title . $after_title; }

		// Widget output
		$dir = get_bloginfo ( 'template_directory' );
		echo '<fb:like-box href="http://www.facebook.com/eSfaturi" width="266" height="350" show_faces="true" border_color="#CCCCCC" stream="false" header="false"></fb:like-box>';

		// After widget
		echo $after_widget;
	}
	
	// Update Settings
	function update($new_instance, $old_instance) {
 		$instance['title'] = strip_tags($new_instance['title']);
 		return $instance;
 	}
	
	// Widget Control Panel
	function form($instance) {
 		$defaults = array( 'title' => 'Social', 'facebookUrl' => '#', 'twitterUrl' => '#', 'gplusUrl' => '#' );
 		$instance = wp_parse_args( (array) $instance, $defaults ); ?>

 		<p>
			<label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
 			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
 		</p>
		
        <?php 
	}
}

// End class csc-social-widget
add_action('widgets_init', create_function('', 'return register_widget("esf_facebook_like_box");'));
?>